/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.raitcon.hibernate.db;

import com.raitcon.hibernate.bean.Alumno;
import com.raitcon.hibernate.bean.Empleado;
import static com.raitcon.hibernate.db.AlumnoDB.log;
import com.raitcon.hibernate.factory.HibernateUtil;
import java.util.List;
import org.apache.log4j.Logger;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 *
 * @author Mike
 */
public class EmpleadoDB {
    
    protected static Logger log = Logger.getLogger(EmpleadoDB.class);
    private Session session = null;
    
    
    public EmpleadoDB() {
        this.session = HibernateUtil.getSessionFactory().getCurrentSession();
    }
    
    
    
    public List<Empleado> getEmployeeByType(String  codType){

        List<Empleado> empleadoList = null;
        try {
            Transaction tx = session.beginTransaction();
            Query q = session.createQuery("from Empleado WHERE tipo_empleado ='"+codType+"'");

            empleadoList = (List<Empleado>) q.list();
        } catch (Exception e) {
            log.debug("Error:" + e.getMessage());
            e.printStackTrace();
        } finally {
            session.close();
        }
        return empleadoList;
    }
    
}
